<!--
 * @Author: rxn 1003312535@qq.com
 * @Date: 2024-04-12 15:40:14
 * @LastEditors: rxn 1003312535@qq.com
 * @LastEditTime: 2024-10-10 10:16:01
 * @FilePath: \vue3-progect\src\components\BaseFormDialog\index.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<!-- 表单弹窗 -->
<template>
	<BaseDialog v-model="dialogVisible" title="新增" width="1000">
		<BaseForm
			:formConfig="formConfig"
			:form="form"
			@returnData="returnData"
		></BaseForm>
	</BaseDialog>
</template>

<script setup lang="ts">
import { computed } from "vue";
const props = defineProps({
	modelValue: { type: Boolean, defalut: false },
	formConfig: { type: Array, required: true },
	form: { type: Object, required: true }
});
const emits = defineEmits(["update:modelValue", "returnFormDialogData"]);
let dialogVisible = computed({
	get: () => props.modelValue,
	set: (val) => {
		emits("update:modelValue", val);
	}
});

/**
 * 触发回调
 * @param option Object
 * -btnType 按钮类型
 */
const returnData = (option = { btnType: "" }) => {
	emits("returnFormDialogData", { done: closeDialog, btnType: option.btnType });
};
/**
 * 关闭弹窗
 */
const closeDialog = () => {
	dialogVisible.value = false;
};
</script>

<style lang="less" scoped></style>
